import urllib.request
import urllib.parse
url = 'https://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=cname'
headers={
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0'
}
for i in range(1, 11):
    data = {'cname': '郑州', 'pid': '', 'pageIndex': i, 'pageSize': '10'}
    data=urllib.parse.urlencode(data).encode('utf-8')
    req=urllib.request.Request(url=url,data=data,headers=headers)
    response=urllib.request.urlopen(req)
    html=response.read().decode('utf-8')
    with open(f'kfc_{i}.json', 'w', encoding='utf-8') as f:
        f.write(html)

